<template>
	<view :class="code==1?'contont cont':'contonts'" v-if="pled.length!=0">
		<view class="" v-if="code=='1'">
		<view class="code">
			<view style="width: 100%;height: 90px;display: flex;justify-content: space-between;">
				<view style="display: flex;flex-direction: column;justify-content: space-between;">
					<view class="" style="color: #000000;font-size: 16px;font-weight: 500;margin-top: 20px;margin-left: 20px;">货主姓名：{{ pled.etusername}}</view>
					<view class="number">
						<view class="numbers" style="margin-left: 15px;color: #042A58;">{{ pled.unitPrice }}元/{{ planadd[0].weightName }}</view>
						<view class="numbers" style="color: #042A58;">
							{{ planadd[0].piece }}{{ planadd[0].weightName }}
						</view>
					</view>
				</view>
			<image src="../../static/img/bge_ch.png" mode="" style="width: 72px;height: 36px;margin-top: 15px;"></image>
			</view>
			<view style="display: flex; font-size: 14px;color: #000000;">
				<view  style="width: 15px;height: 30rpx;margin-left: 20px;margin-right: 7px;">
					<image src="../../static/img/icon_dingwei.png" mode="" style="width: 15px;height: 30rpx;"></image>
				</view>
				<view style="width: 56px;">装货地：</view>
				<view style="width: 245px;">{{ pled.sendAddress }}</view>
			</view>
			<view style="display: flex; font-size: 14px;color: #000000;margin-top: 8px;">
				<view  style="width: 15px;height: 30rpx;margin-left: 20px;margin-right: 7px;">
					<image src="../../static/img/icon_zdz.png" mode="" style="width: 18px;height: 9px;"></image>
				</view>
				<view style="width: 56px;">装货地：</view>
				<view style="width: 245px;">{{ pled.receiveAddress }}</view>
			</view>
		</view>
		<button @click="but">接收</button>
	</view>
	<view style="display: flex;flex-direction: column;align-items: center;" v-if="code=='3'">
		<image src="../../static/img/pic_sb.png" mode=""  style="width: 98px;height: 72px;margin-top: 56px;"></image>
		<text style="color: #000000;font-size: 18px;margin-top: 24px;">接收失败</text>
		<text style="color: #777777;font-size: 15px;margin-top: 10px;">您在处于运输中，请完成运输后再接单~</text>
	</view>
</view>
	
</template>

<script>
	import {ajaxs} from '../../apis.js'
	export default {
		data() {
			return {
				code:"1",
				planadd:[],
				pled:[]
			}
		},
		onLoad(option) {
			uni.showLoading({
				title: '加载中！'
			});
			var that=this
			if(option.id==undefined){
				var id=decodeURIComponent(option.q)
				this.list=id.substring(26).replace(/[^0-9]/ig,"")
				ajaxs({
				url: "/v1/appdriver/driverOrderInfo",
					method: 'post',
					data:{
						id:this.list,
						type:5
					},
					success(res) {
						console.log(res)
						uni.hideLoading();
						that.pled =res.data.message.order;	
							that.planadd = that.planadd.concat(JSON.parse(res.data.message.order.goodsjson));
					}
				});
			}else{
				console.log(option.id)
				this.list=option.id
				ajaxs({
				url: "/v1/appdriver/driverOrderInfo",
					method: 'post',
					data:{
						id:this.list,
						type:5
					},
					success(res) {
						console.log(res)
						uni.hideLoading();
						that.pled =res.data.message.order;	
							that.planadd = that.planadd.concat(JSON.parse(res.data.message.order.goodsjson));
					}
				});
			}
		},
		onShow() {
		},
		methods: {
			but(){
				var that=this
				uni.getStorage({
					key:"name",
					success(res) {
							// 	uni.reLaunch({
							// 		url:"../Receipt/Receipt"
							// })
							ajaxs({
								url:"/v1/appdriver/order/entrust",
								method:"post",
								data:{
									orderId:that.list
								},
								success(res){
									console.log(res)
									if(res.data.status=="OK"){
											uni.reLaunch({
												url:"../Receipt/Receipt"
										})
									}else{
										
									  uni.showToast({
									      title: res.data.message,
									  	icon:"none"
									  })   
									  if(res.data.message=="指派司机驾驶证认证失败，请检查"){
										  setTimeout(function () {
										  			uni.navigateTo({
										  				url:"../ME/carded"
										  		  })
										   },1000)
									  }else{
										  that.code=3
										  setTimeout(function () {
										  		uni.reLaunch({
										  				url:"../Receipt/Receipt"
										  		})
										   },3000)
									  }
									 
									}
								}
							})
							
					},
					fail() {
					uni.navigateTo({
						url:"../index/index?id=1"
					})
					}
				})
			}
		}
	}
</script>

<style>
	page{
		height: 100%;
	}
.code{
	width:355px;
	height:206px;
	background:rgba(255,255,255,1);
	border-radius:8px;
	margin-top: 20rpx;
}
.number{
	display: flex;
	margin-bottom: 15px;
}
.numbers{
	background:rgba(242,243,246,1);
	border-radius:4px;
	display: flex;
	justify-content: space-around;
	align-items: center;
	font-size:12px;
	margin-left: 5px;
	padding: 5px 8px 5px 8px;
}
button{
	width:355px;
	height:50px;
	background:rgba(4,42,88,1);
	border-radius:8px;
	margin-top: 50px;
	color: #FFFFFF;
}
.contonts{
	width: 100%;
	height: 100%;
	position: relative;
	display: flex;
	flex-direction:column ;
	background-color: #FFFFFF;
	align-items: center;
}
.cont{
	background-color: #f5f5f5;
}
</style>
